﻿<%@ WebHandler Language="C#" Class="SIPO.Web.AjaxHandler.Loaddata.getActionDemand" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.Enum;
using SIPO.Web.Support;
using Newtonsoft.Json.Linq;
using System.Text;

namespace SIPO.Web.AjaxHandler.Loaddata
{
    public class getActionDemand : SIPO.Web.BaseHandler
    {
        recActionDemandRepo actionDemandDal = new recActionDemandRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
        string MethodName = string.Empty;
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            if (context.Request.Params["method"] != null)
                MethodName = context.Request.Params["method"];
            
            if(MethodName.Equals("getActionDemandById"))
            {
                int actionID = Convert.ToInt32(context.Request.Params["ActionID"]);
                List<recActionDemand> actionDemand = actionDemandDal.GetList();
                var result = actionDemand.Where(x => x.ActionID == actionID);

                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
            }
        }

        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}